<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>BOM组管理信息</title>
		<link rel="stylesheet" type="text/css"
			href="${pageContext.request.contextPath}/css/public.css">
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/sorttable.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/public.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/validate.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/baseset.js"></script>
			<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/date1.js"></script>
		<script language="JavaScript"
			src="${pageContext.request.contextPath}/js/checkboxSelect.js"></script>

		<script type="text/javascript">
		
	  	function validate(){	
	  	//alert("test");
			var username = document.getElementById("username");
			var rolename = document.getElementById("rolename");
					
			if(!isNotNull(username,'用户名称')||!f_check_ZhOrNumOrLett(username,'用户名称'))
				return false;	
			
			if(!(isNotNull(rolename,'用户组')&&f_check_ZhOrNumOrLett(rolename,'用户组')))
				return false;	
		} 
		
		function getBOMGroup(){			
			var formname = document.getElementById("BOMForm");//form的ID
			formname.action = "getBOMGroup.action";
				formname.submit();
		}
		
		
		//修改BOM组
		function editBOMGroup(){
			var bomGroupIDs = document.getElementsByName("bomGroupID");
			
			var editID="";
			var formname = document.getElementById("BOMForm");//formd的ID

			var bomGroupIDCount = 0;
			
	
			for (var i = 0; i < bomGroupIDs.length; i++) {
				if (bomGroupIDs[i].checked) {
					bomGroupIDCount++;
					editID = editID+bomGroupIDs[i].value+",";
				}
			}
	
			if (bomGroupIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			var array = editID.split(",");	
	 		if (bomGroupIDCount >1) {
				alert("每次修改BOM组只能选择一条记录！");
				return false;
			} else {
				if (bomGroupIDCount == 1) {
					if (confirm("确认要修改该记录吗？")) {
						formname.action = "showEditBOMGroup.action?editBOMGroupID="+array[0];
						formname.submit();
					}
				}
			} 	
		}
		
		//删除用户和用户组
		function deleteBOMGroup(){
			var bomGroupIDs = document.getElementsByName("bomGroupID");
			
			var deletedBomGroupIDs="";
			
			var formname = document.getElementById("BOMForm");//formd的ID

			var bomGroupIDCount = 0;
			
	
			for (var i = 0; i < bomGroupIDs.length; i++) {
				if (bomGroupIDs[i].checked) {
					bomGroupIDCount++;
					deletedBomGroupIDs = deletedBomGroupIDs+bomGroupIDs[i].value+",";
				}
			}
	
		

			
			if (bomGroupIDCount<1) {
				alert("您还没有进行选择！");
				return false;
			} 
			
			if (confirm("确认要删除记录吗？")) {
				// alert("deleteUser.action?deletedUserID="+deletedUserID+"&deletedRoleID="+deletedRoleID);
				formname.action = "deleteBOMGroup.action?deletedBOMGroupID="+deletedBomGroupIDs;
				formname.submit();
			}
		}
		</script>
		
	</head>
  	<body>
		<div id="info_all">
			<div id="info_top">
				BOM组
			</div>
			<!-- 主输入区 -->
			<!-- 功能按钮 -->
			<s:form name="BOMForm" theme="simple"
				cssStyle="margin-top:0px" id="BOMForm">
			<div id="info_main">
				<!-- 信息显示栏 -->
				<!-- 查询栏 -->
				<div id="btn">
					<input type="button" value="新增" onClick="showAddBOMGroup()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
						<input type="button" value="修改" onClick="editBOMGroup()"
						class="btnsize" />
					<input type="button" value="删除" onClick="deleteBOMGroup()"
						onFocus="this.blur()" onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize" />
			</div>
				<div id="select">
					<hr>
						<table>
							<tr>
									<td>
										BOM组代码&nbsp;
									</td>
									<td>
										<input type="text" name="bomGroupCode" size="12" id="bomGroupCode">
										&nbsp;&nbsp;&nbsp;
									</td>
									<td>
										BOM组名称&nbsp;
									</td>
									<td>
										<input type="text" name="bomGroupName" size="12" id="bomGroupName" />
									</td>
								</tr>
						</table>
					
				</div>
				<div class="sele">
					<input type="button" value="查询" onFocus="this.blur()"
						onmouseover="this.className='btnover'" onClick="getBOMGroup()"
						onmouseout="this.className='btnout'" class="btnsize" />
					<input type="reset" value="重置" onFocus="this.blur()"
						onmouseover="this.className='btnover'"
						onmouseout="this.className='btnout'" class="btnsize"/>
						<hr>
				</div>
				<!-- 信息显示栏 -->
				<div id="info_info1">
					<table id="info_table" width="560px"  cellspacing=1px cellpadding=1px  class="sortable">
						<thead>
							<tr align="center">
							<th width="10px">
											<input type="checkbox" onClick="selectAll()" />
										</th>
								<th width="120px">
									BOM组代码
								</th>
								<th width="120px">
									BOM组名称
								</th>
								
								<th width="120px">
									BOM父组名称
								</th>
								<th width="200px">
									查看所属BOM单据
								</th>
								
							</tr>
						</thead>
						<tbody>
						
						
						  <s:iterator value="bomGroupDTOList" status="status">     
							<tr align="center">	
							<td>
												<input type="checkbox" name="bomGroupID" id="bomGroupID"
													value="${bomGroupID}" />
											</td>							
								<td>
									 <s:property value="bomGroupCode"/>
								</td>
								<td>
									 <s:property value="bomGroupName"/> 
								</td>
								<td>
									 <s:property value="bomParentGroupName"/> 
								</td>
								<td >
									 <a href="showBOMBill.action?bomGroupID=<s:property value="bomGroupID"/>">查看</a> 
								</td>
							</tr>
						</s:iterator>  						
						</tbody>
						<tfoot>
							<tr>
							</tr>
						</tfoot>
					</table>

					<script language="javascript">  
						//("表格名称","奇数行背景","偶数行背景","点击后背景");
						 mouseclick("info_table","#ffffff","#ffffff","#e6f0fd");
						 //("表格名称","奇数行背景","偶数行背景");
						 //setcolor("t","#ffffff","#ffffff");
					</script>
				</div>					
			</div>
			</s:form>
		</div>
	
	</body>
</html>